package com.matchmealpha;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.BaseAdapter;


public class CommentListAdapter extends BaseAdapter {

	private Context context;
	private List<Comment> commList;
	private int selectedPosition;
	private int callerID;

	/**
	 * 
	 * @param context
	 * @param friendsList
	 * @param callerID
	 * @param callerType
	 *            - 1 - click to open timeline, 2 - click and return result
	 */
	public CommentListAdapter(Context context, List<Comment> commList,
			int callerID) {
		this.context = context;
		this.commList = commList;
		this.callerID = callerID;
		this.selectedPosition = Adapter.NO_SELECTION;
	}

	public int getSelectedPosition() {
		return this.selectedPosition;
	}

	@Override
	public int getCount() {
		return this.commList.size();
	}

	@Override
	public Object getItem(int position) {
		return this.commList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
		// return this.friendsList.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView != null) {
			((CommentView) convertView).setComment(this.commList.get(position));
		} else {
			convertView = new CommentView(this.context, commList.get(position),
					this.callerID);
		}
		this.selectedPosition = position;
		return convertView;
	}

}
